window.onload =function()
{
    var btn = document.getElementById("registerButton");
    var userName = document.getElementById("userName");
    var usernameTip = document.getElementById("usernameTip");
    var password = document.getElementById("password");
    var passwordAgain = document.getElementById("passwordAgain");
    var passwordTip = document.getElementById("passwordTip");
    var againTip = document.getElementById("againTip");
    var regName = /^[A-Za-z0-9]{6,16}$/;
    btn.disabled = 'disabled';
    window.addEventListener('keyup',function(){
        /*判断用户名是否符合规定 */
        if(typeof userName.value == "undefined" || userName.value == null || userName.value == "")
        {
            usernameTip.style.display = "inline";
        }
        else  if(regName.test(userName.value)==false)
        {
            usernameTip.style.display = "inline";
        }
        else
        {
            usernameTip.style.display = "none";
            //检查密码是否符合规定
            if(typeof password.value=="undefined" || password.value==null || password.value=="")
            {
                passwordTip.style.display = "inline";
            }
            else if(regName.test(password.value)==false)
            {
                passwordTip.style.display = "inline";
            }
            else
            {
                passwordTip.style.display = "none";
                //判断两次密码输入是否一致
                if(password.value != passwordAgain.value)
                {
                    againTip.style.display = "inline";
                }
                else
                {
                    againTip.style.display = "none";
                    btn.disabled=false;
                }
            }
        }
    })

}